﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ByHand.Services.Code
{
    public static class GuuProduct
    {
        public static string Getjsondata(string URL)
        {
            System.Net.HttpWebRequest request = null;
            StreamReader responseReader = null;
            string responseData = "";

            try
            {
                request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(URL);
                responseReader = new StreamReader(request.GetResponse().GetResponseStream());
                responseData = responseReader.ReadToEnd();
            }
            catch
            {
                throw;
            }
            finally
            {
                request.GetResponse().GetResponseStream().Close();
                responseReader.Close();
                responseReader = null;
            }
            return responseData;
        }
        public static string CreateUrlGetDataUpdate(int merchantID, int page, int numberProduct)
        {
            return "http://test.guu.vn/api/getproducts?merchantid=" + merchantID + "&page=" + page + "&pagesize=" + numberProduct;
        }
        public static string CreateGuuOrderUrl(int guuProductID, int[] guuattrID, string name, string phone, string email, string address, int cityID, int districtID, int guuPaytype, int bank)
        {
            string guuattrids = "";
            foreach (var item in guuattrID)
            {
                guuattrids = guuattrids + item + ",";
            }
            return "http://test.guu.vn/api/order?" + "productid=" + guuProductID + "&attributeids=" + guuattrids + "&name=" + name + "&phone=" + phone + "&email=" + email + "&address=" + address + "&cityid=" + cityID + "&districtid=" + districtID + "&coupon=&paymenttype=" + guuPaytype + "&bank=" + bank + "";
        }
    }
}
